/**
 * Created by chenzui on 2017/3/7.
 */
var $staffCode = $("#email");
var $password = $("#password");
var $loginBtn =$("#signIn");
var loginInfo={
    
}
loginInfo.login = function () {
    $(".help-block").text("");
    if($staffCode.val().trim() == ""){
        $(".help-block").text("请输入工号");
        return;
    }
    if($password.val().trim() == ""){
        $(".help-block").text("请输入密码");
        return;
    }
    var param = {
        staffCode: $staffCode.val().trim(),
        password: $password.val().trim()
    };
    Ajax.ajax({
        url: "/staff/login",
        data: param,
        type: "post",
        dataType: 'json',
        success:function(res){
            console.log(res);
            if (res.resultCode == 0) {
                $.cookie('staffCode',res.data,{expires:365*10 ,path: '/'});
                window.location = "/shop/index/index.jsp";
            }else {
                alert(res.data);
                $.cookie('staffCode',null);
            }
        }

    });
}


$(function () {
    $loginBtn.on("click",function () {
        console.log("......")
        loginInfo.login();
    });
})